define(['config/appregister', "business/personalcenter/service/httpServices",
	"business/services/personCenterComp",
	"business/services/detailNavComp",
	"jquery","domReady","dragsort","business/services/filter"],function(app,httpServices){
	app.controller('homepageCtrl',function($scope,$state,$window,$rootScope,auth){
		auth.isPersonLogin();

		$scope.signAll="签到"
		$scope.sign=function(){
			if($scope.signAll=="已签到"){
				alert("已经签到过了")
				getSignCon();
			}else{
				 var req ={
				type:"GET",
				uri:"signUp",
				data:{}
			};
			httpServices.PostSign(req).success(function(data){
				$scope.$apply(function(){
					if(data.msg=="success"){
						$(".moreDay").show(500,function(){
				        $(this).css("opacity","1");
				     }).hide(500,function(){
				     	 $(this).css("opacity","0");
				     });
				     getSignCon();
				     $scope.signAll="已签到"
					}else{
						alert("您已签到过了哦");
						getSignCon();
						$scope.signAll="已签到"
					}
				})
			});
		     
			}

		}
	getSignCon();
		function getSignCon(){
			var req ={
				type:"GET",
				uri:"getSignInfo",
				data:{}
			};
			httpServices.PostSign(req).success(function(data){
				$scope.$apply(function(){
					$scope.signCon = data.data;
					if(data.data.isSign){
						$scope.signAll="已签到"
					}
				})
			});
		}

		//进来判断
		$(".home-op").hide();
		$(".home-op-div1").hide();//首先设置隐藏，再根据判断来测试是否展开
		If();
        $scope.reload=function(){
            $(".home-op").show();
            $(".home-op-div1").show();//首先设置隐藏，再根据判断来测试是否展开
        }
		function If(){
			 var req ={
				type:"GET",
				uri:"getCurrentPersonInfo",
				data:{}
			};
			httpServices.getPerson(req).success(function(data){
				$scope.$apply(function(){
			/*		console.log(JSON.stringify(data))*/
					if(data.data.carrerStatusId != 1 && data.data.carrerStatusId !=2 && data.data.carrerStatusId !=3 ){
						//直接显示页不要弹出层
						$(".home-op").show();
						$(".home-op-div1").show();
					}else{
				//弹出层
					var req ={
						type:"GET",
						uri:"getCurrentPersonInfo",
						data:{}
					};
					httpServices.getPerson(req).success(function(data){
						$scope.$apply(function(){
							if(data.msg=="success"){
								$scope.currentId = data.data.carrerTopId//第一个id
								$scope.scId = data.data.databaseSecondId
								$scope.libId2 = data.data.professionalThirdId;
								$scope.libraId =data.data.professionalSecondId;
								//ajax();
							}
						})
					});
						$(".home-op").hide();
						$(".home-op-div1").hide();
					};
				})
			});
		}
		$scope.key = true;
		$scope.saveTcid= function(item,index){
			$scope.bg = item.scId;
			$scope.scId = item.scId;
			if($scope.key && $scope.oldBg == $scope.bg ){
				$scope.bg=0.1
				$(".floeDIv2").hide()
				$scope.key=false;
			}else{
				var req ={
						type:"GET",
						uri:"getThirdCategory",
						data:{
							scId:item.scId
						}
					};
					httpServices.getTwoColum(req).success(function(data){
						$scope.$apply(function(){
							$scope.ThrColum = data.data;
							
						})
					});
				var top = Math.floor($($(".floeDIv")[index]).offset().top)-100;
				$(".floeDIv2").css("top",top)
				$(".floeDIv2").show()
				$scope.showListCon = index
				$scope.scId =  item.scId;
				$scope.key=false;
				$(".floeDIv2").show()
				$scope.key=true;
				$scope.oldBg = $scope.bg;
			}
		};
		/*点击完成后执行ajax，默认显示数据*/
		$scope.saveThriId=function(item,index){
			$scope.ThrcolumId = item.dcId;
			$scope.currentId=item.dcId;
			$scope.bgfont=index
			ajax()
            $(".floeDIv2").hide()
		}
		$scope.hideThis=function(){
			$(".floeDIv2").hide()	
		}
		$scope.closeOk = function(){
			if($scope.ThrcolumId != undefined){
				$(".home-op").hide();
				$(".home-op-div2").hide();
				var req ={
						type:"POST",
						uri:"modifyPersonMuitlType",
						data:{
							carrerStatusId:$scope.oneID,
							carrerTopId:$scope.currentId,
							databaseSecondId:$scope.bg,
							databaseThirdId:$scope.ThrcolumId
						}
					};
					httpServices.getPerson(req).success(function(data){
						$scope.$apply(function(){
							/*console.log(data)*/
						})
					});
			}else{
				alert("清选择分类");
				return false;
			}

		};
		getNews()
		/*新闻资讯1*/
		function getNews(){
			var req ={
				type:"GET",
				uri:"getEnginNews",
				data:{}
			};
			httpServices.getWorkData(req).success(function(data){
				$scope.$apply(function(){
					$scope.rightNewsList = data.data.rightNewsList;//右边新闻
					$scope.topnews  = data.data.topNews;//中间新闻
					$scope.topnews.content=$scope.topnews.content.replace(/<.*?>/ig,"").replace(/&nbsp;/g,'');
					$scope.topNewsName = data.data.topNews.name
					$scope.leftNewsList= data.data.leftNewsList;//左边新闻

				})
			});
		}
		//百问百答
		$scope.answerColse=function(){
			$(".home-op").hide();
			$(".home-op-div7").hide();
			//百问百答
			getPostbarList();
			modifyPersonMuitlType();
		}
		$scope.saveTcid7=function(item){
			$scope.professionalSecondId = item.scId;
			$scope.oneclass=item.scName;
			/*var req ={
				type:"GET",
				uri:"getThirdCategory?all=true&scId="+$scope.bg7,
				data:{}
			};
			httpServices.getTwoColum(req).success(function(data){
				$scope.$apply(function(){
					$scope.ThreeColum = data.data;//三级栏目数据
				})
			});*/
		}
		//工程论文库

		$scope.saveOneBookId=function(item,$index){
			$scope.bg6=$index;
			$scope.librarySecondId = item.scId;
			var req ={
				type:"GET",
				uri:"getDetailCategory",
				data:{
					scId: item.scId
				}
			};
			httpServices.getstu(req).success(function(data){
				$scope.$apply(function(){
					$scope.stuMenuTwoCon2 = data.data;//论文
				})
			});
		}
		$scope.saveBoookid2=function(item,$index){
			$scope.libraryThirdId = item.dcId;
		}
		$scope.BookClose=function(){
			getEnginLibrary();
			$('.home-op-div6').hide();
			$(".home-op").hide();
			modifyPersonMuitlType();
		}
		//工程E学堂
		$scope.videoColse=function(){
			$(".home-op-div5").hide();
			$(".home-op").hide();
			getVideo();
			modifyPersonMuitlType();
		}
		$scope.saveTcid5=function(item){
			$scope.videoTopId=item.tcId;
			var req ={
				type:"GET",
				uri:"getSecondaryCategory?tcId="+item.tcId,
				data:{}
			};
			httpServices.getTwoColum(req).success(function(data){
				$scope.$apply(function(){
					$scope.ThreeColum = data.data.list;//三级栏目数据
				})
			});
		}
		$scope.ThreeColumId5=function(item){
			$scope.videoSecondId = item.scId;
		}
		//工程资料库
		$scope.saveTcid2=function(item){
			$scope.databaseSecondId=item.scId;
			var req ={
				type:"GET",
				uri:"getThirdCategory?scId="+item.scId,
				data:{}
			};
			httpServices.getTwoColum(req).success(function(data){
				$scope.$apply(function(){
					$scope.ThreeColum = data.data;//三级栏目数据
				})
			});
		}
		$scope.ThreeColumId = function(item){
			$scope.databaseThirdId = item.dcId;
		}
		$scope.DataColse=function(){
			if(!!$scope.databaseSecondId && !!$scope.databaseThirdId ){
				$(".home-op").hide();
				$(".home-op-div4").hide();
				getWorkData();
				modifyPersonMuitlType();
			}else{
				alert("请选择子分类")
			}
		}

		//职业规划
		$scope.colseSwitch=function(){
			if(!!$scope.carrerTopId){
				$(".home-op").hide();
				$(".home-op-div3").hide();
				work();
				modifyPersonMuitlType();
			}else{
				alert("请选择分类")
			}
		}
		$scope.saveScid=function(item){
			$scope.carrerTopId = item.hierId;
		};



		function modifyPersonMuitlType(){
			var req ={
				type:"POST",
				uri:"modifyPersonMuitlType",
				data:{
					carrerStatusId:$scope.carrerStatusId,
					professionalSecondId:$scope.professionalSecondId,
					professionalThirdId:$scope.professionalThirdId,
					databaseSecondId:$scope.databaseSecondId,
					databaseThirdId:$scope.databaseThirdId,
					carrerTopId:$scope.carrerTopId,
					librarySecondId:$scope.librarySecondId,
					libraryThirdId:$scope.libraryThirdId,
					videoTopId:$scope.videoTopId,
					videoSecondId:$scope.videoSecondId
				}
			};
			httpServices.getPerson(req).success(function(response){
				$scope.$apply(function(){

				})
			})
		}
		function getPersonMuitlType(){
			var req ={
				type:"GET",
				uri:"getPersonMuitlType",
				data:{}
			};
			httpServices.getPerson(req).success(function(response){
				$scope.$apply(function(){
					$scope.carrerStatusId = response.data.carrerStatusId;
					$scope.professionalSecondId = response.data.professionalSecondId;
					$scope.professionalThirdId = response.data.professionalThirdId;
					$scope.databaseSecondId = response.data.databaseSecondId;
					$scope.databaseThirdId = response.data.databaseThirdId;
					$scope.carrerTopId = response.data.carrerTopId;
					$scope.librarySecondId = response.data.librarySecondId;
					$scope.libraryThirdId = response.data.libraryThirdId;
					$scope.videoTopId = response.data.videoTopId;
					$scope.videoSecondId = response.data.videoSecondId;
					getWorkData();
					work();
					getVideo();
					getPostbarList();
					getEnginLibrary();//论文图书馆
					$scope.Timg=1;
				})
			})
		}
		getPersonMuitlType();

		function ajax(){
			getNews()
			getWorkData();
			work();
			getVideo();
			getPostbarList();
			getEnginLibrary();//论文图书馆
			$scope.Timg=1;
		}
		function getEnginLibrary(){
			var req ={
				type:"GET",
				uri:"getEnginLibrary?scId="+$scope.librarySecondId+"&dcId="+$scope.libraryThirdId+"&count=7",
				data:{}
			};
			httpServices.getWorkData(req).success(function(data){
				$scope.$apply(function(){
					if(data.data){
						$scope.libraryList= data.data.libraryList;//论文图书馆
					}
				})
			});
		}
		function getWorkData(){
			var req ={
				type:"GET",
				uri:"getEnginFile?scId="+$scope.databaseSecondId+"&dcId="+$scope.databaseThirdId+"&count=9",
				data:{}
			};
			httpServices.getWorkData(req).success(function(data){
				$scope.$apply(function(){
					//$scope.topFile = data.data.topFile;//左侧文档
					$scope.price = data.data.list[0].price;//文档积分
					$scope.name = data.data.list[0].name;//文档名字
					$scope.Workid = data.data.list[0].file;//文档id
					$scope.topFile = data.data.list[0];
					$scope.centerFile = data.data.list.slice(1,5);
					$scope.rightFile = data.data.list.slice(5);
				})
			});
		}//工程资料库
		function work(){//职业规划
			var req ={
				type:"GET",
				uri:"getProfePlann?hierId="+$scope.carrerTopId+"&grade=1&count=3",
				data:{}
			};
			httpServices.getWorkData(req).success(function(data){
				$scope.$apply(function(){
					console.log(data)
					$scope.total = data.data;
					$scope.logo = data.data.plannHier;//左侧图片地址
					$scope.workDateLilst = data.data.skillList;//工程技能

					$scope.courseList = data.data.courseList//工程课程
					$scope.fileList = data.data.fileList//工程资料
				})
			});
		}

		function getVideo(){//培训视频
			var req ={
				type:"GET",
				uri:"getEnginCourse?tcId="+$scope.videoTopId+"&scId="+$scope.videoSecondId+"&dcId=0&count=6",
				data:{}
			};
			httpServices.getWorkData(req).success(function(data){
				$scope.$apply(function(){
					if(data.data){
						$scope.videoData = data.data.courseList;
					}

				})
			});
		}
		function getPostbarList(){//百问百答
			var req ={
				type:"GET",
				uri:"getPostbarList",
				data:{
					scId:$scope.professionalSecondId,
					hierId:$scope.carrerTopId,
					count:3
				}
			};
			httpServices.getbotbar(req).success(function(data){
				$scope.$apply(function(){
					$scope.TotalNum = data.data.sum[0].totalCount;//问题总数
					$scope.solveCount = data.data.sum[0].answerCount;//已解决问题数量
					$scope.unSolveCount = data.data.sum[0].unanswerCount;//未解决问题数量
					$scope.solvePrecent = ($scope.solveCount/$scope.TotalNum).toFixed(2)*100;//已解决百分比
					var unSolvePrecent =Number(($scope.unSolveCount/$scope.TotalNum).toFixed(2));//未解决百分比;

					$scope.unSolvePrecent = unSolvePrecent*100
					/*左边分类*/
					if(data.data.category.length!=0){
						$scope.anserLeft = data.data.category[0].postbarList;//专业那的
						$scope.oneclass = data.data.category[0].tcName;
						$scope.twoclass=data.data.category[0].scName;
					}
					/*中间分类*/
					if(data.data.hier.length!=0){
						$scope.anserCenter = data.data.hier[0].postbarList;//职业
						$scope.hirName=data.data.hier[0].hierName;
					}
				})
			});

			$scope.novice=function(){
				$scope.Timg=1;
				var req ={
					type:"GET",
					uri:"getProfePlann?hierId="+$scope.carrerTopId+"&grade=1&count=3",
					data:{}
				};
				httpServices.getWorkData(req).success(function(data){
					$scope.$apply(function(){
						$scope.logo = data.data.plannHier;//左侧图片地址
						$scope.workDateLilst = data.data.skillList;//工程技能
						$scope.courseList = data.data.courseList//工程课程
						$scope.fileList = data.data.fileList//工程资料
					})
				});//默认职业规划
			}
			$scope.AP=function(){
				/*alert("1")*/
				$scope.Timg=2;
				var req ={
					type:"GET",
					uri:"getProfePlann?hierId="+$scope.carrerTopId+"&grade=2&count=3",
					data:{}
				};
				httpServices.getWorkData(req).success(function(data){
					$scope.$apply(function(){
						$scope.logo = data.data.plannHier;//左侧图片地址
						$scope.workDateLilst = data.data.skillList;//工程技能
						$scope.courseList = data.data.courseList//工程课程
						$scope.fileList = data.data.fileList//工程资料
					})
				});
			}

		}

		function getWokrStatus(){
			 var req ={
				type:"GET",
				uri:"getCarrerStatusList",
				data:{}
			};
			httpServices.getAdd(req).success(function(data){
				$scope.$apply(function(){
					/*console.log(JSON.stringify(data))*/
					$scope.workStadus = data.data;
				})
			});
		}
		getWokrStatus();
		$scope.LastStep=function(){
			$(".home-op-div1").show();
			$(".home-op-div2").hide();
		}
		/*点击大导航跳转*/
		$scope.myTab=[
			{title:"我的博文",state:"bloglist"},
			{title:"简历管理",state:"resume.posted"},
			{title:"我的账户",state:"myaccount"},
			{title:"我的工程界",state:"myMainPage"}
		];
		// 点击我的分页面 进行跳转
		$scope.myRoutes = [
			{title:"我的上传",state:"prosonMine.myUpload"},
			{title:"我的下载",state:"prosonMine.myDownload"},
			{title:"我的课程",state:"prosonMine.myVedios"},
			{title:"我的问答",state:"prosonMine.myQuestions"},
			{title:"我的评论",state:"prosonMine.myComment"},
			{title:"我的收藏",state:"prosonMine.myCollection"},
			{title:"我的好友",state:"prosonMine.myFriends",type:'fansEachother'},
			{title:"我的消息",state:"prosonMine.myMessage"},
		];
		$scope.stateGoToState = function(state){
			if(!state)return ;
			if(state == 'myMainPage'){
				$state.go(state,{
					userId:$rootScope.userLoginInfo.data.userId
				})
			}else{
				$state.go(state);
			}
		};
		$scope.stateJump = function(item){
			if(item.hasOwnProperty('type')){
				$state.go(item.state,{type:item.type})
			}else{
				$state.go(item.state);
			}
		};
		//用户职业选择弹出层静态效果
		$scope.btnone = function(id){
			$scope.oneID = id;
			$scope.currentId =-1;
			getcolumn();
		};
		/*ajax服务*/

		/*第一个栏目*/
		function getcolumn(){
			var req ={
				type:"GET",
				uri:"getCareerPlann?pageSize=100",
				data:{}
			};
			httpServices.getcolumn(req).success(function(data){
				$scope.$apply(function(){
					$scope.columns = data.data.list;
					
				})
			});
		};
		getcolumn();
		function getstu(){
			var req ={
				type:"GET",
				uri:"getSecondaryCategory",
				data:{
					tcId:"3"
				}
			};
			httpServices.getstu(req).success(function(data){
				$scope.$apply(function(){
					$scope.stuMenu = data.data;
					/*console.log(JSON.stringify($scope.stuMenu))*/
				})
			});
		}
		getstu();
		$scope.savelib=function(item,$index){
			$scope.DinName=$index;
			$scope.libId2 = item.dcId;
		}
		$scope.saveMajorId=function(item,index){
			$scope.className=index;
			var id = item.scId;
			$scope.libraId = id;//论文图书馆id
			var req ={
				type:"GET",
				uri:"getDetailCategory",
				data:{
					scId:id
				}
			};
			httpServices.getstu(req).success(function(data){
				$scope.$apply(function(){
					$scope.stuMenuTwoCon = data.data;
				})
			});
		}
		$scope.saveDIc=function(item,index){
			$scope.currentId=item.dcId;
			$scope.DinName=index
		}
		//点击下一步
		$scope.next = function(){
			if($scope.currentId != undefined){
				$(".home-op-div1").hide();
				$(".home-op-div2").show();
				function getTwoColum(){
					var req ={
						type:"GET",
						uri:"getSecondaryCategory",
						data:{
							tcId:1,
							pageSize:100
						}
					};
					httpServices.getTwoColum(req).success(function(data){
						$scope.$apply(function(){
							$scope.TwoColum = data.data.list;
						})
					});
				}
				getTwoColum();
			}else{
				alert("请选择分类");
				return false;
			}

		};
			function getTwoColum(){
					var req ={
						type:"GET",
						uri:"getTopCategory",
						data:{}
					};
					httpServices.getTwoColum(req).success(function(data){
						$scope.$apply(function(){
							$scope.TwoColum = data.data;
						})
					});
				}
				getTwoColum();
				function getSecondary(){
					var req ={
						type:"GET",
						uri:"getSecondaryCategory",
						data:{
							all:true,
							tcId:1
						}
					};
					httpServices.getTwoColum(req).success(function(data){
						$scope.$apply(function(){
							$scope.getSecondary = data.data.list;
						})
					});
				}
				getSecondary();
		//关闭定制类目层
		/*$scope.closeOk = function(){
			if($scope.scId != undefined){
				$(".home-op").hide();
				$(".home-op-div2").hide();
			}else{
				alert("清选择分类");
				return false;
			}

		};*/
		$scope.saveColumId=function(item){
			$scope.currentId =  item.hierId;
			$scope.hirName=$scope.oneclass = item.hierName;
		};
		$scope.saveColumId1=function(item,index){
			$scope.currentId =  item.hierId;
			$scope.color2 =  index;
		};
		$scope.saveColumId2=function(item,index){
			$scope.currentId =  item.hierId;
			$scope.color3 =  index;
		};
		$scope.saveColumId3=function(item,$index){
			$scope.currentId =  item.hierId;
			$scope.colorWOrk =  $index;
		}
		/*点击完成后执行ajax，默认显示数据*/


		/*视频列表跳转*/
		//跳转各个详情页
		$scope.goTo = function(item){
			$state.go("eng.vedioDetails",{courseId:item.courseId})
		}
		$scope.go=function(){
			$state.go('eng.iask')
		}

		/*定制你的专属通道*/
		$scope.saveTcidChanner=function(item,index){
			$scope.bgChan=item.scId;
			
			$scope.bgfont=index
			$(".floeDIvs2").hide();
		}
	
		function saveModule(){

			arr = JSON.stringify($scope.postXiaojunHuang)
			console.log(arr)
	
			 var req ={
				type:"POST",
				uri:"addCustom",
				data:{
					jsonPc:arr
				}
				
			};
			httpServices.getpersonCustom(req).success(function(data){
				$scope.$apply(function(){
//					$scope.postXiaojunHuang = [];
//		 			$scope.dragSort = [];
					getPerSonCustom();
				})
			});
		
		}
		//拖动插件
		$("#modelDragsort").dragsort({
			dragSelector: "div.modelTitle",      //容器拖动手柄
			dragBetween: true,                   //
			dragEnd:saveOrder,                   //执行之后的回调函数
			dragSelectorExclude : "div.modelContent",     //指定不会执行动作的元素
			placeHolderTemplate: "<li class='placeHolder'><div></div></li>",     //拖动列表的HTML部分
			scrollSpeed: 50  ,          //拖动速度
		});
		function saveOrder(){
			//var num = $(this).data('itemidx');
			var data = $("#modelDragsort li").map(function () { return $(this).data("sortid"); }).get();
			
			
			for(var i = 0;i < $scope.postXiaojunHuang.length;i++){
				$scope.postXiaojunHuang[i].moduleId = data[i];
			}
			for(var i = 0;i < $scope.dataArr.length;i++){
				$scope.dataArr[i].sequence = i;
				$scope.postXiaojunHuang.push($scope.dataArr[i]);
			}
			$scope.dataArr = [];
			saveModule();
			
		}
		function getPerSonCustom(){
		 var req ={
				type:"GET",
				uri:"getPersonCustom",
				data:{}
			};
			httpServices.getpersonCustom(req).success(function(respons){
				$scope.$apply(function(){
					$scope.dragSort = respons.data;
					$scope.postXiaojunHuang = [];
					for(var i = 0;i < respons.data.length;i++){
						if(respons.data[i].isDisplay == 1){
							$(".showMychannel .iconActive").eq(respons.data[i].moduleId-1).addClass('icongray')
						}
					}
					/*var modulId = respons.data[0].moduleId;
					var OneDisplay = respons.data[0].isDisplay;
						switch(modulId){
							case 1:
								if(OneDisplay>0){
									$($(".iconActive")[0]).attr("class","icongray")
								}
								break;
							case 2:
								if(OneDisplay>0){
									$($(".iconActive")[2]).attr("class","icongray")
								}
								break;
								
							case 3:
							if(OneDisplay>0){
									$($(".iconActive")[3]).attr("class","icongray")
								}
								break;
							
							case 4:
							if(OneDisplay>0){
									$($(".iconActive")[4]).attr("class","icongray")
								}
								break;
								
							case 5:
								if(OneDisplay>0){
									$($(".iconActive")[5]).attr("class","icongray")
								}
								break;
							
							case 6:
								if(OneDisplay>0){
									$($(".iconActive")[6]).attr("class","icongray")
								}
								break;
						}
						var modulIdTwo = respons.data[1].moduleId;
						var OneDisplayTwo = respons.data[1].isDisplay;
						switch(modulIdTwo){
							case 1:
								if(OneDisplayTwo>0){
									$($(".iconActive")[0]).attr("class","icongray")
								}
								break;
							case 2:
								if(OneDisplayTwo>0){
									$($(".iconActive")[2]).attr("class","icongray")
								}
								break;
								
							case 3:
							if(OneDisplayTwo>0){
									$($(".iconActive")[3]).attr("class","icongray")
								}
								break;
							
							case 4:
							if(OneDisplayTwo>0){
									$($(".iconActive")[4]).attr("class","icongray")
								}
								break;
								
							case 5:
								if(OneDisplayTwo>0){
									$($(".iconActive")[5]).attr("class","icongray")
								}
								break;
							
							case 6:
								if(OneDisplayTwo>0){
									$($(".iconActive")[6]).attr("class","icongray")
								}
								break;
						}
						
						var modulIdThr = respons.data[2].moduleId;
						var OneDisplayThr = respons.data[2].isDisplay;
						switch(modulIdThr){
							case 1:
								if(OneDisplayThr>0){
									$($(".iconActive")[0]).attr("class","icongray")
								}
								break;
							case 2:
								if(OneDisplayThr>0){
									$($(".iconActive")[2]).attr("class","icongray")
								}
								break;
								
							case 3:
							if(OneDisplayThr>0){
									$($(".iconActive")[3]).attr("class","icongray")
								}
								break;
							
							case 4:
							if(OneDisplayThr>0){
									$($(".iconActive")[4]).attr("class","icongray")
								}
								break;
								
							case 5:
								if(OneDisplayThr>0){
									$($(".iconActive")[5]).attr("class","icongray")
								}
								break;
							
							case 6:
								if(OneDisplayThr>0){
									$($(".iconActive")[6]).attr("class","icongray")
								}
								break;
						}
						
						
						var modulIdfou = respons.data[3].moduleId;
						var OneDisplayFou = respons.data[3].isDisplay;
						switch(modulIdfou){
							case 1:
								if(OneDisplayFou>0){
									$($(".iconActive")[0]).attr("class","icongray")
								}
								break;
							case 2:
								if(OneDisplayFou>0){
									$($(".iconActive")[2]).attr("class","icongray")
								}
								break;
								
							case 3:
							if(OneDisplayFou>0){
									$($(".iconActive")[3]).attr("class","icongray")
								}
								break;
							
							case 4:
							if(OneDisplayFou>0){
									$($(".iconActive")[4]).attr("class","icongray")
								}
								break;
								
							case 5:
								if(OneDisplayFou>0){
									$($(".iconActive")[5]).attr("class","icongray")
								}
								break;
							
							case 6:
								if(OneDisplayFou>0){
									$($(".iconActive")[6]).attr("class","icongray")
								}
								break;
						}
						
						
						var modulIdfive = respons.data[4].moduleId;
						var OneDisplayFive = respons.data[4].isDisplay;
						switch(modulIdfive){
							case 1:
								if(OneDisplayFive>0){
									$($(".iconActive")[0]).attr("class","icongray")
								}
								break;
							case 2:
								if(OneDisplayFive>0){
									$($(".iconActive")[2]).attr("class","icongray")
								}
								break;
								
							case 3:
							if(OneDisplayFive>0){
									$($(".iconActive")[3]).attr("class","icongray")
								}
								break;
							
							case 4:
							if(OneDisplayFive>0){
									$($(".iconActive")[4]).attr("class","icongray")
								}
								break;
								
							case 5:
								if(OneDisplayFive>0){
									$($(".iconActive")[5]).attr("class","icongray")
								}
								break;
							
							case 6:
								if(OneDisplayFive>0){
									$($(".iconActive")[6]).attr("class","icongray")
								}
								break;
						}
						
							var modulIdsix = respons.data[5].moduleId;
							var OneDisplaysix = respons.data[5].isDisplay;
						switch(modulIdsix){
							case 1:
								if(OneDisplaysix>0){
									$($(".iconActive")[0]).attr("class","icongray")
								}
								break;
							case 2:
								if(OneDisplaysix>0){
									$($(".iconActive")[2]).attr("class","icongray")
								}
								break;
								
							case 3:
							if(OneDisplaysix>0){
									$($(".iconActive")[3]).attr("class","icongray")
								}
								break;
							
							case 4:
							if(OneDisplaysix>0){
									$($(".iconActive")[4]).attr("class","icongray")
								}
								break;
								
							case 5:
								if(OneDisplaysix>0){
									$($(".iconActive")[5]).attr("class","icongray")
								}
								break;
							
							case 6:
								if(OneDisplaysix>0){
									$($(".iconActive")[6]).attr("class","icongray")
								}
								break;
						}*/
					

					$scope.dataArr = [];
					for(var i = 0;i < respons.data.length;i++){
						$('#dramode'+respons.data[i].moduleId).attr('data-sortId',respons.data[i].moduleId);
						if(respons.data[i].isDisplay == 1){
							$('#dramode'+respons.data[i].moduleId).hide();
							$scope.dataArr.push(respons.data[i]);
						}else{
							$scope.postXiaojunHuang.push(respons.data[i]);
						}
						
					}
					for(var i = 0;i < $scope.postXiaojunHuang.length;i++){
						$('#modelDragsort').append($('#dramode'+$scope.postXiaojunHuang[i].moduleId));
					}

					/*var id1 = data.data[0].moduleId;
					if(id1==0 && data.data[0].isDisplay==1){
						$(".home-div3").css("display","none");
					}*/
					
				})
			});
		}
		
		
		$scope.colseChannel = function(){

			$(".home-op").hide();
			$(".showMychannel").hide();
			$scope.postXiaojunHuang = $scope.dragSort;
		};
		$scope.arr3=[]
		$scope.saveTcidChanner2=function(item,$index){
			$scope.bgChan3=item.excluId;
			var num = $index;
			item.isHover = !item.isHover;
			var html =	$($(".chann").get(num)).text();
			var nowModuleId,index;
			switch(html){
				case "职业规划":
					nowModuleId = 1;
					break;
				case "工程资料库":
					nowModuleId = 2;
					break;
				case "工程e学堂":
					nowModuleId = 3;
					break;
				case "工程论文库":
					nowModuleId = 4;
					break;
				case "百问百答":
					nowModuleId = 5;
					break;
				case "工程头条":
					nowModuleId = 6;
					break;
				//case "工程技能":
				//	nowModuleId = 7;
				//	break;
			}
			
			for(var i = 0;i < $scope.dragSort.length;i++){
				if($scope.dragSort[i].moduleId == nowModuleId){
					index = i;
				}
			}
			console.log(nowModuleId,item.isHover)
			if(item.isHover){
				for(var i = 0;i < $scope.postXiaojunHuang.length;i++){
					if($scope.postXiaojunHuang[i].moduleId == nowModuleId){
						$scope.postXiaojunHuang[i].isDisplay = 1;
						$scope.dataArr.push($scope.postXiaojunHuang[i]);
						$scope.postXiaojunHuang.splice(i,1);
					}
				}
				$('#dramode'+nowModuleId).hide();
			} else {
                for(var i = 0;i < $scope.dataArr.length;i++){
					if($scope.dataArr[i].moduleId == nowModuleId){
						$scope.dataArr[i].isDisplay = 0;
						$scope.postXiaojunHuang.push($scope.dataArr[i]);
						$scope.dataArr.splice(i,1);
					}
				}
                $('#dramode'+nowModuleId).show();
            }
		}
		function getChannel(){
			var req ={
				type:"GET",
				uri:"getExclusive",
				data:{}
			};
			httpServices.getWorkData(req).success(function(data){
				$scope.$apply(function(){
				getPerSonCustom();
				
					$scope.channer = data.data;
					$scope.name0 = data.data[0].name;//职业规划
					$scope.name1 = data.data[1].name;//工程技能
					$scope.name2 = data.data[2].name;//工程资料库
					$scope.name3 = data.data[3].name;//培训视频
					$scope.name4 = data.data[4].name;//论文图书馆
					$scope.name5 = data.data[5].name;//百问百答
					$scope.name6 = data.data[6].name;//新闻资迅
				})
			});
		}
		getChannel();
		$scope.ThreeColumIdChanner=function(item){
			$scope.bgChan2=item.dcId
		}
		$scope.Mychannel=function(){
			$(".home-op").show();
			$(".showMychannel").show();
			$(document).scrollTop(400)
		};
		$scope.saveTcidcha=function(item,index){
			$scope.bg = item.scId;
			$scope.scId = item.scId;	
			var req ={
				type:"GET",
				uri:"getThirdCategory",
				data:{
					scId:item.scId
				}
			};
			httpServices.getTwoColum(req).success(function(data){
				$scope.$apply(function(){
					$scope.ThrColum = data.data;

				})
			});
			
			
			$scope.bg=item.scId;
			var top = Math.floor($($(".floeDIvs")[index]).position().top)+80;
			$(".floeDIvs2").css("top",top)
			$(".floeDIvs2").show()
			$scope.showListCon = index
			$scope.scId =  item.scId;
			$scope.key=false;
			$(".floeDIvs2").show()

			
		};
		$scope.colseChannel2 = function(item){
				if($scope.dataArr){
					for(var i = 0;i < $scope.dataArr.length;i++){
						$scope.dataArr[i].isDisplay = 1;
						$scope.postXiaojunHuang.push($scope.dataArr[i])
					}
				}

				if($scope.postXiaojunHuang.length == 6){
					saveModule();
				}
				
				$(".home-op").hide();
				$(".showMychannel").hide();
				var scId = $scope.bg;
				var tcId = $scope.bgChan;//hired tcid
				function getWorkData(){
					var req ={
						type:"GET",
						uri:"getEnginFile?scId="+scId+"&dcId="+tcId+"&count=9",
						data:{}
					};
					httpServices.getWorkData(req).success(function(data){
						$scope.$apply(function(){
							$scope.detailFileList = data.data.detailFileList;//右侧详细1
							$scope.topFile = data.data.topFile;//左侧文档
							$scope.price = data.data.topFile.price;//文档积分
							$scope.name = data.data.topFile.name;//文档名字
							$scope.Workid = data.data.topFile.skillId;//文档id
						})
					});
				}//工程资料库
				function work(){//职业规划
					var req ={
						type:"GET",
						uri:"getProfePlann?hierId="+tcId+"&grade=1&count=3",
						data:{}
					};
					httpServices.getWorkData(req).success(function(data){
						$scope.$apply(function(){
							if(data.data.skillList){
							$scope.videoCon = data.data.skillList;//视频内容
							}
							else if(data.data.hierStepList){
								$scope.hierStepList = data.data.hierStepList//最后工程技能
							}
							$scope.courseList = data.data.courseList//中间资料
							$scope.logo = data.data.plannHier;//左侧图片地址	
						})
					});
				}

				function getEnginPostBar(){//百问百答
					var req ={
						type:"GET",
						uri:"getEnginPostBar?scId="+scId+"&dcId="+tcId+"&hierId="+tcId+"&count=3",
						data:{

						}
					};
					httpServices.getWorkData(req).success(function(data){
						$scope.$apply(function(){
							var TotalSolveCon = data.data.postbarCount;//已经解决问题列表
							$scope.TotalNum = TotalSolveCon[0].totalCount;//问题总数
							$scope.solveCount = TotalSolveCon[0].solveCount;//已解决问题数量
							$scope.unSolveCount = TotalSolveCon[0].unSolveCount;//未解决问题数量
							$scope.solvePrecent = TotalSolveCon[0].solvePrecent;//已解决百分比
							$scope.unSolvePrecent = TotalSolveCon[0].unSolvePrecent;//未解决百分比;
							/*左边分类*/
							$scope.anserLeft = data.data.postbarCateList;//专业那的
							/*中间分类*/
							$scope.anserCenter = data.data.postbarProfeList;//专业中间
						})
					});
				}
				function paper2(){
					var req ={
						type:"GET",
						uri:"getEnginLibrary?scId="+scId+"&dcId="+tcId+"&count=8",
						data:{}
					};
					httpServices.getWorkData(req).success(function(data){
						$scope.$apply(function(){
							$scope.libraryList= data.data.libraryList;//论文图书馆
						})
					});
				}
				/*getWorkData();
				work();
				getVideo();
				getAnswer();
				paper2();//论文图书馆*/
		};
        $scope.downfile=function(a){
        
            window.open("http://"+allUrl+":8083/elink_database/api/file/download?fileId="+a+"&seed="+ localStorage.seed + "&authToken=" + localStorage.authToken,"_blank")
        }
		



		function getEnginFile(){
			var req ={
				type:"GET",
				uri:"getEnginFile?scId="+$scope.bg3+"&dcId="+$scope.bg4+"&count=9",
				data:{}
			};
			httpServices.getWorkData(req).success(function(data){
				$scope.$apply(function(){

					$scope.detailFileList = data.data.detailFileList;//右侧详细1
					$scope.topFile = data.data.topFile;//左侧文档
					$scope.price = data.data.topFile.price;//文档积分
					$scope.name = data.data.topFile.name;//文档名字
					$scope.Workid = data.data.topFile.skillId;//文档id
				})
			});
		}




		$scope.ThreeColumId7 = function(item){
			$scope.bg7_1 = item.dcId;
            $scope.twoclass=item.dcName;
		}


		function recentBrowse(){
			var req ={
				type:"GET",
				uri:"getEnginBrowse?count=6",
				data:{}
			};
			httpServices.getWorkData(req).success(function(data){
				$scope.$apply(function(){
					console.log(data.data)
					$scope.recentCon = data.data.enginBrowseList;
				})
			});
		}
		recentBrowse();
		$scope.btntwo = function(id){
			$scope.colorWOrk=-1;
			$scope.oneID = id;
			getcolumn();
		};

		$scope.btnthree = function(id){
			$scope.oneID = id;
		}

		//更换内容按钮
		/*职业规划切换内容*/
		$scope.Open3 = function(){
			$(".home-op").show();
			$(".home-op-div3").show();
			
		};


		function Switchajax(){
			var req ={
				type:"GET",
				uri:"getProfePlann?hierId="+$scope.switchId+"&grade=1&count=3",
				data:{}
			};
			httpServices.getWorkData(req).success(function(data){
				$scope.$apply(function(){
					$scope.logo = data.data.plannHier;//左侧图片地址
					$scope.videoCon = data.data.skillList;//视频内容
					$scope.courseList = data.data.courseList//中间资料
					$scope.fileList = data.data.fileList//最后工程技能
				})
			});
		}
		$scope.close3 = function(){
			$(".home-op").hide();
			$(".home-op-div3").hide();
		};
		/*定制你的专属通道内容*/
		$scope.saveID=function(item){
			$scope.bg3 = item.scId;
		};



		/*function getEnginLibrary(){
			var req ={
				type:"GET",
				uri:"getEnginLibrary?scId="+$scope.BookId+"&dcId="+$scope.Bookwid+"&count=8",
				data:{}
			};
			httpServices.getWorkData(req).success(function(data){
				$scope.$apply(function(){
					if(data.data== null){

						$scope.libraryList = null;
						$(".home-op").hide();
						$(".home-op-div6").hide();
					}else{
						$scope.libraryList= data.data.libraryList;
						$(".home-op").hide();
						$(".home-op-div6").hide();
					}
				})
			});
		}*/
		$scope.closeMy=function(){
			$(".home-op").hide();
			$(".myIcon").hide();
		}

		$scope.Open4 = function(){
			$(".home-op").show();
			$(".home-op-div4").show();
		}
		$scope.Open5 = function(){
			$(".home-op").show();
			$(".home-op-div5").show();
		}
		$scope.Open6 = function(){
			$(".home-op").show();
			$(".home-op-div6").show();
		}
		$scope.Open7 = function(){
			$(".home-op").show();
			$(".home-op-div7").show();
		}

		//移入移出显示文字提示
		$scope.showto8 = function(){
			$(".tishi8").html("按住可拖动上下位置");
		}
		$scope.hideto8 = function(){
			$(".tishi8").html("");
		}

		$scope.showto7 = function(){
			$(".tishi7").html("按住可拖动上下位置");
		}
		$scope.hideto7 = function(){
			$(".tishi7").html("");
		}

		$scope.showto6 = function(){
			$(".tishi6").html("按住可拖动上下位置");
		}
		$scope.hideto6 = function(){
			$(".tishi6").html("");
		}

		$scope.showto5 = function(){
			$(".tishi5").html("按住可拖动上下位置");
		}
		$scope.hideto5 = function(){
			$(".tishi5").html("");
		}

		$scope.showto4 = function(){
			$(".tishi4").html("按住可拖动上下位置");
		}
		$scope.hideto4 = function(){
			$(".tishi4").html("");
		}

		$scope.showto3 = function(){
			$(".tishi3").html("按住可拖动上下位置");
		}
		$scope.hideto3 = function(){
			$(".tishi3").html("按住可拖动上下位置");
		}

		//更改内容box里的关闭按钮
		$scope.close7 = function(){
			$(".home-op").hide();
			$(".home-op-div7").hide();
		}
		$scope.close6 = function(){
			$(".home-op").hide();
			$(".home-op-div6").hide();
		}
		$scope.close5 = function(){
			$(".home-op").hide();
			$(".home-op-div5").hide();
		}
		$scope.close4 = function(){
			$(".home-op").hide();
			$(".home-op-div4").hide();
		}
		
		
		$scope.delWork=function(){
			var msg = "您真的确定要删除吗？删除后将从列表中消失\n\n请确认！";
			if (confirm(msg)==true){
				$(".home-div3").hide()
				$($(".iconActive")[0]).attr("class","icongray")
			for(var i=0;i<$scope.postXiaojunHuang.length;i++){
					if($scope.postXiaojunHuang[i].moduleId==1){
						$scope.postXiaojunHuang[i].isDisplay = 1;
					}
				}
				if($scope.dataArr){
					for(var i = 0;i < $scope.dataArr.length;i++){
						$scope.dataArr[i].sequence = i;
						$scope.postXiaojunHuang.push($scope.dataArr[i]);
					}
				}
				

			saveModule();
				
				
			}else{
				return false;
			}
		}

		$scope.delWorkData=function(){
			var msg = "您真的确定要删除吗？删除后将从列表中消失\n\n请确认！";
			if (confirm(msg)==true){
				$(".home-div4").hide()
				$($("。iconActive")[2]).attr("class","icongray")
			for(var i=0;i<$scope.postXiaojunHuang.length;i++){
					if($scope.postXiaojunHuang[i].moduleId==2){
						$scope.postXiaojunHuang[i].isDisplay = 1;
					}
				}
				if($scope.dataArr){
					for(var i = 0;i < $scope.dataArr.length;i++){
						$scope.dataArr[i].sequence = i;
						$scope.postXiaojunHuang.push($scope.dataArr[i]);
					}
				}
				

			saveModule();
				
			}else{
				return false;
			}
		}
		$scope.delWorkVideo=function(){
			var msg = "您真的确定要删除吗？删除后将从列表中消失\n\n请确认！";
			if (confirm(msg)==true){
				$(".home-div5").hide()
				$($("。iconActive")[3]).attr("class","icongray")
				for(var i=0;i<$scope.postXiaojunHuang.length;i++){
					if($scope.postXiaojunHuang[i].moduleId==3){
						$scope.postXiaojunHuang[i].isDisplay = 1;
					}
				}
				if($scope.dataArr){
					for(var i = 0;i < $scope.dataArr.length;i++){
						$scope.dataArr[i].sequence = i;
						$scope.postXiaojunHuang.push($scope.dataArr[i]);
					}
				}
				

			saveModule();
				
			}else{
				return false;
			}
		}
		$scope.delpaper=function(){
			var msg = "您真的确定要删除吗？删除后将从列表中消失\n\n请确认！";
			if (confirm(msg)==true){
				$(".home-div6").hide()
				$($(".iconActive")[4]).attr("class","icongray")
				var sortid = $("#dramode4").attr("data-sortid");
				for(var i=0;i<$scope.postXiaojunHuang.length;i++){
					if($scope.postXiaojunHuang[i].moduleId==4){
						$scope.postXiaojunHuang[i].isDisplay = 1;
					}
				}
				if($scope.dataArr){
					for(var i = 0;i < $scope.dataArr.length;i++){
						$scope.dataArr[i].sequence = i;
						$scope.postXiaojunHuang.push($scope.dataArr[i]);
					}
				}
				
			saveModule();
			}else{
				return false;
			}
			
		
		}
		$scope.delAnswer=function(){
			var msg = "您真的确定要删除吗？删除后将从列表中消失\n\n请确认！";
			if (confirm(msg)==true){
				$(".home-div7").hide()
				$($("。iconActive")[5]).attr("class","icongray")
			for(var i=0;i<$scope.postXiaojunHuang.length;i++){
					if($scope.postXiaojunHuang[i].moduleId==5){
						$scope.postXiaojunHuang[i].isDisplay = 1;
					}
				}
				if($scope.dataArr){
					for(var i = 0;i < $scope.dataArr.length;i++){
						$scope.dataArr[i].sequence = i;
						$scope.postXiaojunHuang.push($scope.dataArr[i]);
					}
				}
				

			saveModule();
				
			}else{
				return false;
			}
		}
		$scope.delnewList=function(){
			var msg = "您真的确定要删除吗？删除后将从列表中消失\n\n请确认！";
			if (confirm(msg)==true){
				$(".home-div8").hide()
				$($("。iconActive")[6]).attr("class","icongray")
			for(var i=0;i<$scope.postXiaojunHuang.length;i++){
					if($scope.postXiaojunHuang[i].moduleId==6){
						$scope.postXiaojunHuang[i].isDisplay = 1;
					}
				}
				if($scope.dataArr){
					for(var i = 0;i < $scope.dataArr.length;i++){
						$scope.dataArr[i].sequence = i;
						$scope.postXiaojunHuang.push($scope.dataArr[i]);
					}
				}
				

			saveModule();
				
			}else{
				return false;
			}
			
		}
		$scope.goLibrary = function(item){
			$state.go('eng.libraryDetail',{thesisId:item.thesisId})
		}
		$scope.goworkData=function(id){
			$state.go("eng.techdetail",{fileId:id})
		}
		$scope.goFillList=function(){
			$state.go("eng.main")
		}
		$scope.goSkill=function(id){
			$state.go("eng.workDetailsCtrl",{skillId:id})
		}
		$scope.gowok=function(id){
			$state.go("eng.workDetailsCtrl",{skillId:id})
		}
		$scope.goWOlrlist=function(){
			$state.go("eng.careerPlanDetail",{hierId:$scope.carrerTopId})
		}
		$scope.govideoDe=function(id){
			$state.go("eng.vedioDetails",{courseId:id})
		}
		$scope.goVideo=function(){
			$state.go("eng.vedio")
		}
		$scope.LinkCourse=function(id){
			$state.go("eng.vedioDetails",{courseId:id})
		}
		$scope.goanswer=function(id){
			$state.go("eng.postbardeta",{postbarId:id})
		}
		$scope.goNews = function(id){
			$state.go("eng.newsDetail",{newsId:id})
		}
		$scope.linkcareerPlanMain=function(){
			$state.go("eng.careerPlanDetail",{hierId:$scope.carrerTopId})
		}
		$scope.linkData=function(){
			$state.go("eng.main")
		}
		$scope.linkVideo=function(){
			$state.go("eng.vedio")
		}
		$scope.linklibraryMain=function(){
			$state.go("eng.libraryMain")
	}
		$scope.Linkwikilist=function(){
			$state.go("eng.wikilist")
		}
		$scope.lInkNews=function(){
			$state.go("eng.newsList")
		}
		$scope.Linklibrary=function(id){
			$state.go("eng.libraryDetail",{thesisId:id})
		}
		$scope.Linkpostbar=function(id){
			$state.go("eng.libraryDetail",{thesisId:id})
		}
		$scope.tab=0;
		$scope.showlistOne=function(){
			$scope.tab=1;
			$(".home-op-div1").animate(
				{"height":420}
			)
		}
		$scope.showlistTwo=function(){
			$scope.tab=2;
			$(".home-op-div1").animate(
				{"height":420}
			)
		}
		$scope.showlistThr=function(){
			$scope.tab=3;
			$scope.className=-1;
			$scope.DinName=-1;
			$scope.color3 =-1;
			$(".home-op-div1").animate(
				{"height":580}
			)
			
		}
		$scope.swithDea=function(id){
			if(id == undefined){
				
			}else{
				$state.go("eng.careerPlanDetail",{hierId:id})
			}
			
		}
		//获取未读消息
		function getUnreadCount(){
			var req ={
				type:"GET",
				uri:"getUnreadCount"
			};
			httpServices.notifyHttpService(req).success(function(data){
				$scope.$apply(function(){
					if(!data.data){
						return;
					}
					$scope.notNotify = data.data;
				})
			});
		}
		getUnreadCount()
	})





})



















